#include "vlmodebutton.h"
#include "GUIDebug.h"

VLModeButton::VLModeButton(const QString &mode, QWidget *parent) :
    QPushButton(parent), modeVal(mode) {
    mouseDown = false;
}

VLModeButton::VLModeButton(const QString &text, const QString &mode, QWidget *parent) :
    QPushButton(text, parent), modeVal(mode) {
    mouseDown = false;
}

VLModeButton::VLModeButton(const QIcon &icon, const QString &text, const QString &mode, QWidget *parent) :
    QPushButton(icon, text, parent), modeVal(mode) {
    mouseDown = false;
}

void VLModeButton::click() {
    emit clicked(modeVal);
}

void VLModeButton::mousePressEvent(QMouseEvent *e) {
    if (mouseDown == false) {
        mouseDown = true;
    }
}
void VLModeButton::mouseReleaseEvent(QMouseEvent *e) {
    if (mouseDown == true) {
        mouseDown = false;
        click();
    }
}
